import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
   {
    title: '创建日期',
    align:"center",
    dataIndex: 'createTime'
   },
   {
    title: '产品名称',
    align:"center",
    dataIndex: 'productName'
   },
   {
    title: '版本号',
    align:"center",
    dataIndex: 'version'
   },
   {
    title: '应用ID',
    align:"center",
    dataIndex: 'appid'
   },
   {
    title: 'APK',
    align:"center",
    dataIndex: 'url',
   },
   {
    title: '热更新地址',
    align:"center",
    dataIndex: 'wgturl',
   },
   {
    title: '更新说明',
    align:"center",
    dataIndex: 'note'
   },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
	{
      label: "产品名称",
      field: 'productName',
      component: 'Input',
      //colProps: {span: 6},
 	},
	{
      label: "版本号",
      field: 'version',
      component: 'Input',
      //colProps: {span: 6},
 	},
	{
      label: "应用ID",
      field: 'appid',
      component: 'Input',
      //colProps: {span: 6},
 	},
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '产品名称',
    field: 'productName',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入产品名称!'},
          ];
     },
  },
  {
    label: '版本号',
    field: 'version',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入版本号!'},
          ];
     },
  },
  {
    label: '应用ID',
    field: 'appid',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入应用ID!'},
          ];
     },
  },
  {
    label: 'APK',
    field: 'url',
    component: 'JUpload',
    componentProps:{
     },
  },
  {
    label: '热更新地址',
    field: 'wgturl',
    component: 'JUpload',
    componentProps:{
     },
  },
  {
    label: '更新说明',
    field: 'note',
    component: 'InputTextArea',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入更新说明!'},
          ];
     },
  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];

// 高级查询数据
export const superQuerySchema = {
  createTime: {title: '创建日期',order: 0,view: 'datetime', type: 'string',},
  productName: {title: '产品名称',order: 1,view: 'text', type: 'string',},
  version: {title: '版本号',order: 2,view: 'text', type: 'string',},
  appid: {title: '应用ID',order: 3,view: 'text', type: 'string',},
  url: {title: 'APK',order: 4,view: 'file', type: 'string',},
  wgturl: {title: '热更新地址',order: 5,view: 'file', type: 'string',},
  note: {title: '更新说明',order: 6,view: 'textarea', type: 'string',},
};

/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[]{
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}